#!/bin/sh
 
dir="/opt/leetcode/"
fileName=$1
fullPath=${dir}/${fileName}

if [ -e $fullPath ]
then
        echo "文件已存在"
else
        touch ${fullPath}
        echo "#include<stdio.h>" >> $fullPath
        echo "#include<stdlib.h>" >> $fullPath
        echo -e "\n" >> $fullPath
        echo "int main()" >> $fullPath
        echo "{" >> $fullPath
        echo -e "\n" >> $fullPath
        echo "}" >> $fullPath
        cat $dir/Makefile_tpl > $dir/Makefile
        sed -i "s/fileName/${fileName}/g" ${dir}/Makefile
fi